package com.ayoka.ui.operate_result;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

import com.ayoka.R;
import com.ayoka.base.BaseActivity;
import com.ayoka.base.BasePresenter;
import com.ayoka.databinding.ActivityOperateResultBinding;
import com.ayoka.mvp.CourseAssignmentMVP.CourseAssignmentPresenter;
import com.jcp.baselibrary.model.ToolBarOptions;

import java.io.Serializable;

/**
 * @author jcp
 * @ClassName: TopicListActivity
 * @Description:
 * @date 2018-12-28 下午4:21:18
 */
public class OperateResultActivity extends BaseActivity<ActivityOperateResultBinding, BasePresenter>  {

    public static int OPERATE_BESPOKE_COACH = 0x001;
    public static int OPERATE_PAY_COMPLETE = 0x002;
    public static int OPERATE_COURSE_COMPLETE = 0x003;

    public static void start(Activity activity, int operateType, Serializable argument) {
        Intent intent = new Intent(activity, OperateResultActivity.class);
        intent.putExtra("OperateType", operateType);
        intent.putExtra("Argument", argument);
        activity.startActivity(intent);
    }

    // 操作类型
    private int operateType;
    // 参数
    private Serializable argument;

    @Override
    protected void configIntentValue() {
        operateType = getIntent().getIntExtra("OperateType", 0);
        argument = getIntent().getSerializableExtra("Argument");
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_operate_result;
    }

    @Override
    protected void initViews() {
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        ToolBarOptions options = new ToolBarOptions();
        options.navigateId = R.mipmap.icon_close_black_cross;
        setCustomToolBar(mDataBinding.customToolbar.toolbar, options);

        configFragment();
    }


    @Override
    protected CourseAssignmentPresenter getPresenter() {
        return null;
    }

    private void configFragment() {
        Fragment currentFragment = null;
        if (operateType == OPERATE_BESPOKE_COACH) {
            currentFragment = OperateBespokeCoachFragment.newInstance(argument);
        } else if (operateType == OPERATE_PAY_COMPLETE) {

        } else if (operateType == OPERATE_COURSE_COMPLETE) {

        }
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.frameLayout, currentFragment).commitAllowingStateLoss();
    }
}
